package com.bluegalaxy.nhb.snapi.core.config;


import com.bluegalaxy.nhb.snservice.core.exception.SignException;
import com.bluegalaxy.nhb.snservice.core.exception.XxException;
import com.bluegalaxy.nhb.snservice.domain.vo.api.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by IntelliJ IDEA.
 *
 * @description: To change this template use File | Settings | File Templates.
 */
@ControllerAdvice
public class SignControllerAdvice {

    /**
     * 拦截捕捉自定义异常 SignException.class
     * @param ex
     * @return
     */
    @ResponseBody
    @ExceptionHandler(value = SignException.class)
    public R myErrorHandler(SignException ex) {
        return R.fail(ex.getMessage());
    }

    /**
     * 拦截捕捉自定义异常 SinoAirException.class
     * @param ex
     * @return
     */
    @ResponseBody
    @ExceptionHandler(value = XxException.class)
    public R xxErrorHandler(XxException ex) {
        return R.fail(ex.getMessage());
    }

}
